package rm.member.webapi.webPlugins.mz;

import kd.bos.bill.IBillWebApiPlugin;
import kd.bos.entity.api.ApiResult;
import rm.cq.common.core.consts.ResponseData;
import rm.cq.common.core.enums.ResponseCodeEnum;
import rm.member.business.domain.DTO.GiftGoodsDTO;
import cn.hutool.core.bean.BeanUtil;
import rm.member.business.domain.DTO.GoodsPromotionPageDTO;
import rm.member.business.domain.DTO.OrderInfoDTO;
import rm.member.business.service.GiftGoodsForTerminalService;
import rm.member.business.service.impl.GiftGoodsForTerminalServiceImpl;
import rm.member.ext.MyApiResult;

import java.util.Map;

/**
 * 获取赠品活动信息
 */
public class GetGoodsPromotionPageApiPlugin implements IBillWebApiPlugin {

    private GiftGoodsForTerminalService giftGoodsForTerminalService =new GiftGoodsForTerminalServiceImpl();


    @Override

    public ApiResult doCustomService(Map<String, Object> params) {
        OrderInfoDTO orderInfoDTO = BeanUtil.toBean(params, OrderInfoDTO.class);
        ResponseData<GoodsPromotionPageDTO> responseData = giftGoodsForTerminalService.getGoodsPromotionPage(orderInfoDTO);
        if (responseData.getCode().equals(ResponseCodeEnum.OK.getCode())) {
            MyApiResult myApiResult = new MyApiResult(responseData.getCode(),responseData.getData(),responseData.getMessage(),"12345");
            return myApiResult;
        }
        return new  MyApiResult(responseData.getCode(),responseData.getData(),responseData.getMessage(),"12345");
    }
}
